<?php
//
defined('BY_JYA') or exit('error');
cfc('core')->checklogin();
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$busys = array('0'=>'空闲中','1'=>'已入座','2'=>'已下单','3'=>'已付款');
$return=array();
$return['setting']=$this->plugin_setting('basic');
$return['diy']=$this->plugin_setting('diy');
if($_RQ['op']=='list'){
	$categories = pdo_getall('jy_gohome_serve_category',array('status'=>1,'uniacid'=>$_SESSION['uniacid']),'','','displayorder asc');
	$carts=$this->session('carts');
	$allnum =0;
	if($carts){
		foreach($carts as $k=>&$v){
			$allnum += $v['num'];
		}
	}else{
		$carts=array();
	}
	foreach($categories as &$v){
		$v['serve']=pdo_getall('jy_gohome_serve',array('status'=>1,'uniacid'=>$_SESSION['uniacid'],'categoryid'=>$v['id']),'','','paixu asc');
		if($$v['serve']){
			foreach($v['serve'] as &$row){
				$num1=pdo_count('jy_gohome_order',array('uniacid'=>$_SESSION['uniacid'],'serve_id'=>$row['id'],'status'=>'1'));
				$num2=pdo_count('jy_gohome_order',array('uniacid'=>$_SESSION['uniacid'],'serve_id'=>$row['id'],'status'=>'2'));
				$num3=pdo_count('jy_gohome_order',array('uniacid'=>$_SESSION['uniacid'],'serve_id'=>$row['id'],'status'=>'4'));
				$item['num']=$num1+$num2+$num3;
			}
		}
	}
	$allprice = $goodsprice - $youhui;
	$return['categories']=$categories;
	$return['carts']=$carts;
	set_html('title','上门服务');
	exi($return);
}
/*
if($_RQ['op']=='diancai'){
	$goodid=intval($_RQ['goodid']);
	$num=intval($_RQ['num']);
	$packageid=intval($_RQ['packageid']);
	$carts=$this->session('carts');
	if(!$carts){
		$carts=array();
	}
	$carts[$goodid]['num']=$num;
	if($num == 0){
		unset($carts[$goodid]);
	}
	$goodinfo=pdo_get('jy_dish_goods',array('uniacid'=>$_SESSION['uniacid'],'id'=>$goodid));
	$packageinfo=json_decode($goodinfo['package'],true);
	$package=$carts[$goodid]['package'];
	if(!empty($packageinfo)){
		foreach($packageinfo as $k=>$v){
			if($k == $packageid){
				if($_RQ['plus']){
					$package[$k] +=1;
				}else{
					$package[$k] -=1;
					if($package[$k] == 0){
						unset($packageinfo[$i]);
					}
				}
			}
		}
		$carts[$goodid]['package'] = $package;
	}
	$carts=$this->session('carts',$carts);
	exi($carts);
}
*/
?>